package com.yuwei.video

import android.os.CountDownTimer
import android.widget.TextView
import com.alibaba.android.arouter.launcher.ARouter
import com.yuwei.base.RoutePath
import com.yuwei.common.mvi.BaseViewActivity
import com.yuwei.common.view.CircleCountDownView
import com.yuwei.video.databinding.ActivitySplashBinding

class SplashActivity : BaseViewActivity<ActivitySplashBinding>() {
    lateinit var countDownTimer: CountDownTimer

    override fun initView() {
//        val textView = findViewById<TextView>(R.id.tv)
//        countDownTimer = object : CountDownTimer(4000, 1000) {
//            override fun onTick(millisUntilFinished: Long) {
//                textView.text = "跳过 " + millisUntilFinished / 1000+"s"
//            }
//
//            override fun onFinish() {
//                ARouter.getInstance().build(RoutePath.LOGIN_ACTIVITY).navigation()
//
//                finish()
//            }
//        }.start()
//        textView.setOnClickListener {
//            countDownTimer.cancel()
////            ARouter.getInstance().build(RoutePath.LOGIN_ACTIVITY).navigation()
//            ARouter.getInstance().build(RoutePath.MAIN_ACTIVITY).navigation()
//            finish()
//        }
        binding.cdv.startCountDown()
        binding.cdv.setOnCountDownFinishListener(object : CircleCountDownView.OnCountDownFinishListener{
            override fun onCountDownFinish() {
                ARouter.getInstance().build(RoutePath.MAIN_ACTIVITY).navigation()
                finish()
                binding.cdv.cancelCountDown()
            }

        })
        binding.cdv.setOnClickListener {
            ARouter.getInstance().build(RoutePath.MAIN_ACTIVITY).navigation()
            finish()
            binding.cdv.cancelCountDown()
        }
    }

    override fun initData() {

    }
    override fun onDestroy() {
        super.onDestroy()
//        countDownTimer.cancel()

    }
}